﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace WeiSha.Core
{
	// Token: 0x02000005 RID: 5
	public class RESTfulAPI
	{
		// Token: 0x17000007 RID: 7
		// (get) Token: 0x06000020 RID: 32 RVA: 0x00002956 File Offset: 0x00000B56
		public static RESTfulAPI Get
		{
			get
			{
				return RESTfulAPI._get;
			}
		}

		// Token: 0x06000021 RID: 33 RVA: 0x00002960 File Offset: 0x00000B60
		private RESTfulAPI()
		{
			this._rooNode = PlatformInfoHandler.Node("RESTfulAPI");
		}

		// Token: 0x17000008 RID: 8
		// (get) Token: 0x06000022 RID: 34 RVA: 0x000029D0 File Offset: 0x00000BD0
		public bool HostCheck
		{
			get
			{
				bool flag = this._hostCheck == null;
				if (flag)
				{
					this._hostCheck = new bool?(this._rooNode.AttrValue("hostcheck").Boolean ?? true);
				}
				return this._hostCheck.Value;
			}
		}

		// Token: 0x17000009 RID: 9
		// (get) Token: 0x06000023 RID: 35 RVA: 0x00002A34 File Offset: 0x00000C34
		public bool PageCheck
		{
			get
			{
				bool flag = this._pageCheck == null;
				if (flag)
				{
					this._pageCheck = new bool?(this._rooNode.AttrValue("pagecheck").Boolean ?? true);
				}
				return this._pageCheck.Value;
			}
		}

		// Token: 0x1700000A RID: 10
		// (get) Token: 0x06000024 RID: 36 RVA: 0x00002A98 File Offset: 0x00000C98
		public bool EnableCache
		{
			get
			{
				bool flag = this._enableCache == null;
				if (flag)
				{
					this._enableCache = new bool?(this._rooNode.AttrValue("cache").Boolean ?? true);
				}
				return this._enableCache.Value;
			}
		}

		// Token: 0x1700000B RID: 11
		// (get) Token: 0x06000025 RID: 37 RVA: 0x00002AFC File Offset: 0x00000CFC
		public bool EnableBlack
		{
			get
			{
				bool flag = this._enableBlack == null;
				if (flag)
				{
					PlatformInfoHandler.SiteInfoHandlerParaNode[] children = this._rooNode.Children;
					foreach (PlatformInfoHandler.SiteInfoHandlerParaNode siteInfoHandlerParaNode in children)
					{
						bool flag2 = "black".Equals(siteInfoHandlerParaNode.Attribute("key"), StringComparison.OrdinalIgnoreCase);
						if (flag2)
						{
							this._enableBlack = new bool?(siteInfoHandlerParaNode.Value.Boolean ?? true);
						}
					}
				}
				return this._enableBlack == null || this._enableBlack.Value;
			}
		}

		// Token: 0x1700000C RID: 12
		// (get) Token: 0x06000026 RID: 38 RVA: 0x00002BAC File Offset: 0x00000DAC
		public bool EnableWhite
		{
			get
			{
				bool flag = this._enableWhite == null;
				if (flag)
				{
					PlatformInfoHandler.SiteInfoHandlerParaNode[] children = this._rooNode.Children;
					foreach (PlatformInfoHandler.SiteInfoHandlerParaNode siteInfoHandlerParaNode in children)
					{
						bool flag2 = "white".Equals(siteInfoHandlerParaNode.Attribute("key"), StringComparison.OrdinalIgnoreCase);
						if (flag2)
						{
							this._enableWhite = new bool?(siteInfoHandlerParaNode.Value.Boolean ?? true);
						}
					}
				}
				return this._enableWhite == null || this._enableWhite.Value;
			}
		}

		// Token: 0x1700000D RID: 13
		// (get) Token: 0x06000027 RID: 39 RVA: 0x00002C5C File Offset: 0x00000E5C
		public List<string> BlackList
		{
			get
			{
				List<string> list;
				if ((list = this._blackList) == null)
				{
					list = (this._blackList = this._getlist("black", this._blackList));
				}
				return list;
			}
		}

		// Token: 0x1700000E RID: 14
		// (get) Token: 0x06000028 RID: 40 RVA: 0x00002C90 File Offset: 0x00000E90
		public List<string> WhiteList
		{
			get
			{
				List<string> list;
				if ((list = this._whiteList) == null)
				{
					list = (this._whiteList = this._getlist("white", this._whiteList));
				}
				return list;
			}
		}

		// Token: 0x06000029 RID: 41 RVA: 0x00002CC4 File Offset: 0x00000EC4
		private List<string> _getlist(string key, List<string> list)
		{
			list = new List<string>();
			PlatformInfoHandler.SiteInfoHandlerParaNode[] children = this._rooNode.Children;
			PlatformInfoHandler.SiteInfoHandlerParaNode siteInfoHandlerParaNode = null;
			foreach (PlatformInfoHandler.SiteInfoHandlerParaNode siteInfoHandlerParaNode2 in children)
			{
				bool flag = key.Equals(siteInfoHandlerParaNode2.Attribute("key"), StringComparison.OrdinalIgnoreCase);
				if (flag)
				{
					siteInfoHandlerParaNode = siteInfoHandlerParaNode2;
					break;
				}
			}
			bool flag2 = siteInfoHandlerParaNode != null && siteInfoHandlerParaNode.Children != null;
			if (flag2)
			{
				foreach (PlatformInfoHandler.SiteInfoHandlerParaNode siteInfoHandlerParaNode3 in siteInfoHandlerParaNode.Children)
				{
					list.Add(siteInfoHandlerParaNode3.Value.String);
				}
			}
			return list;
		}

		// Token: 0x0600002A RID: 42 RVA: 0x00002D72 File Offset: 0x00000F72
		public bool WhitePassed(string host)
		{
			return this._listPassed(host, this.WhiteList);
		}

		// Token: 0x0600002B RID: 43 RVA: 0x00002D81 File Offset: 0x00000F81
		public bool BlackPassed(string host)
		{
			return this._listPassed(host, this.BlackList);
		}

		// Token: 0x0600002C RID: 44 RVA: 0x00002D90 File Offset: 0x00000F90
		private bool _listPassed(string host, List<string> list)
		{
			bool flag = host.IndexOf(":") > -1;
			if (flag)
			{
				host = host.Split(new char[] { ':' })[0];
			}
			return list.Any((string item) => host.Equals(item, StringComparison.CurrentCulture));
		}

		// Token: 0x04000007 RID: 7
		private static readonly RESTfulAPI _get = new RESTfulAPI();

		// Token: 0x04000008 RID: 8
		private PlatformInfoHandler.SiteInfoHandlerParaNode _rooNode;

		// Token: 0x04000009 RID: 9
		private bool? _hostCheck = null;

		// Token: 0x0400000A RID: 10
		private bool? _pageCheck = null;

		// Token: 0x0400000B RID: 11
		private bool? _enableCache = null;

		// Token: 0x0400000C RID: 12
		private bool? _enableBlack = null;

		// Token: 0x0400000D RID: 13
		private bool? _enableWhite = null;

		// Token: 0x0400000E RID: 14
		private List<string> _blackList = null;

		// Token: 0x0400000F RID: 15
		private List<string> _whiteList = null;
	}
}
